package com.ln.test.db;

import com.ln.adoms.entity.Brand;
import com.ln.adoms.service.BrandService;
import org.junit.Test;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xi
 * Date: 13-6-30
 * Time: PM6:27
 * To change this template use File | Settings | File Templates.
 */
public class JBrandAction extends DBBase {


    @Resource
    private BrandService brandService;


    @Test
    public void testBrand() {
        List<Brand> list = brandService.findAll();

        for (Brand b : list) {
            System.out.println(b.getName());
        }

        String sql = "select brand_id from brand_department where department_id = 1";
        List<Integer> ids = brandService.find(sql);
        System.out.println("----------------------");
        for (Integer id : ids) {
            System.out.println(id);
        }

        System.out.println("----------------------");
        List<Brand> list2 = brandService.findListByIds(ids);
        for (Brand b : list2) {
            System.out.println(b.getName());
        }
    }

    @Test
    public void testBrand2() {
        List<Brand> list = brandService.findBrandByDepartmentID(1);

        for (Brand b : list) {
            System.out.println(b.getName());
        }

    }

}
